#include<bits/stdc++.h>
using namespace std;
int t,n,m,L,V;
int d[100005];
int a[100005];
int v[100005];
int p[100005];
int num;
vector<int> mo[100005];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int k = 1;k<=t;k++)
    {
        cin>>n>>m>>L>>V;
        int cs=0;
        memset(d,0,sizeof(d));
        memset(a,0,sizeof(a));
        memset(v,0,sizeof(v));
        memset(p,0,sizeof(p));
        for(int i = i;i<=n;i++)
        {
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i = i;i<=m;i++)
        {
            cin>>p[i];
        }
        for(int i = 1;i<=n;i++)
        {
            if((a[i]==0) && (v[i]>V))
            {
                cs++;
                int x = lower_bound(p+1,p+n+1,d[i])-p;
                for(int j = x;j<=m;j++)
                {
                    mo[i].push_back(j);
                }
            }
            if((a[i]>0)&&(v[i]>V))
            {
                cs++;
                int x = lower_bound(p+1,p+n+1,d[i])-p;
                for(int j = x;j<=m;j++)
                {
                    mo[i].push_back(j);
                }
            }
            if((a[i]>0)&&(v[i]<=V))
            {
                int l = d[i]+(V*V-v[i]*v[i])/(2*a[i]);
                if(l<p[m])
                {
                    cs++;
                    int x = upper_bound(p+1,p+n+1,l)-p;
                    for(int j = x;j<=m;j++)
                    {
                        mo[i].push_back(j);
                    }
                }
            }
            if((a[i]< 0) && (v[i]>V))
            {
                int l = d[i]+(V*V-v[i]*v[i])/(2*a[i]);
                int x = lower_bound(p+1,p+n+1,d)-p;
                if(l>p[x])
                {
                    cs++;
                    int y = lower_bound(p+1,p+n+1,l)-p;
                    for(int j = x;j<y;j++)
                    {
                        mo[i].push_back(j);
                    }
                }
            }
        }
        cout<<cs<<" ";
        int z[100005];
        int tot = 0;
        bool car = false;
        for(int i = 1;i<=n;i++)
        {
            if(mo[i].size()==1)
            {
                if(z[mo[i][0]]==0)
                {
                    z[mo[i][0]]=1;
                    tot++;
                }
                continue;
            }
            if(mo[i].empty())
            {
                continue;
            }
            for(int j = 0;j<mo[i].size();j++)
            {
                if(z[mo[i][j]]==1)
                {
                    break;
                }
                z[mo[i][j]]=1;
                car=true;
            }
            if(car==true)
            {
                tot++;
            }
        }
        cout<<(m-tot)<<endl;
    }
    return 0;
}